package org.apache.ibatis.song_test;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;

/**
 * @Description: test：类描述
 * @author: songzhangyong
 * @Date: 2019/11/9 10:56
 */

public class MyBatisTestST {


    public static void main(String[] args) throws IOException {

        String resource = "/Users/song/Documents/D/songFile/源码解读/mybatis/mybatissong/src/main/resources/" +
                "mybatis.xml";
//        InputStream inputStream = Resources.getResourceAsStream(resource);
        InputStream inputStream = new FileInputStream(new File(resource));

        //这一步完成了mybatis.xml 文件的所有解析操作
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(inputStream);

        factory.getConfiguration().addMapper(SequenceDao.class);

        SqlSession session = factory.openSession();

//　　我们先来看第一种形式的sql语句执行也就是SqlSession.getMapper除外的形式。这里还是以带参数的session.selectOne为例子。其实现代码为：
//        session.selectOne();

        List<Map<String, String>> query = session.getMapper(SequenceDao.class).query();

        System.out.println(query);

        System.out.println("-===================");


    }



}
